home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / m / sin.man < prev    next >
Encoding:
Text File  |  1989-06-07  |  4.9 KB  |  199 lines

  1.  
  2.  
  3.  
  4. SIN              Mathematical Library Procedures              SIN
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      sin, cos, tan, asin, acos, atan, atan2 - trigonometric func-
  10.      tions and their inverses
  11.  
  12. SSYYNNOOPPSSIISS
  13.      ##iinncclluuddee <<mmaatthh..hh>>
  14.  
  15.      ddoouubbllee ssiinn((xx))
  16.      ddoouubbllee xx;;
  17.  
  18.      ddoouubbllee ccooss((xx))
  19.      ddoouubbllee xx;;
  20.  
  21.      ddoouubbllee ttaann((xx))
  22.      ddoouubbllee xx;;
  23.  
  24.      ddoouubbllee aassiinn((xx))
  25.      ddoouubbllee xx;;
  26.  
  27.      ddoouubbllee aaccooss((xx))
  28.      ddoouubbllee xx;;
  29.  
  30.      ddoouubbllee aattaann((xx))
  31.      ddoouubbllee xx;;
  32.  
  33.      ddoouubbllee aattaann22((yy,,xx))
  34.      ddoouubbllee yy,,xx;;
  35.  
  36. DDEESSCCRRIIPPTTIIOONN
  37.      Sin, cos and tan return trigonometric functions of radian
  38.      arguments x.
  39.  
  40.      Asin returns the arc sine in the range -pi/2 to pi/2.
  41.  
  42.      Acos returns the arc cosine in the range 0 to pi.
  43.  
  44.      Atan returns the arc tangent in the range -pi/2 to pi/2.
  45.  
  46.      On a VAX,
  47.      atan2(y,x) :=   atan(y/x)                   if x > 0,
  48.                      sign(y)*(pi - atan(|y/x|))  if x < 0,
  49.                      0                           if x = y = 0, or
  50.                      sign(y)*pi/2                if x = 0 != y.
  51.  
  52. DDIIAAGGNNOOSSTTIICCSS
  53.      On a VAX, if |x| > 1 then asin(x) and acos(x) will return
  54.      reserved operands and _e_r_r_n_o will be set to EDOM.
  55.  
  56. NNOOTTEESS
  57.      Atan2 defines atan2(0,0) = 0 on a VAX despite that previ-
  58.      ously atan2(0,0) may have generated an error message.  The
  59.      reasons for assigning a value to atan2(0,0) are these:
  60.  
  61.  
  62.  
  63. Sprite v1.0               May 12, 1986                          1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SIN              Mathematical Library Procedures              SIN
  71.  
  72.  
  73.  
  74.      (1) Programs that test arguments to avoid computing
  75.          atan2(0,0) must be indifferent to its value.  Programs
  76.          that require it to be invalid are vulnerable to diverse
  77.          reactions to that invalidity on diverse computer sys-
  78.          tems.
  79.  
  80.      (2) Atan2 is used mostly to convert from rectangular (x,y)
  81.          to polar (r,theta) coordinates that must satisfy x =
  82.          r*cos theta and y = r*sin theta.  These equations are
  83.          satisfied when (x=0,y=0) is mapped to (r=0,theta=0) on a
  84.          VAX.  In general, conversions to polar coordinates
  85.          should be computed thus:
  86.                   r := hypot(x,y);      ... := sqrt(x*x+y*y)
  87.               theta := atan2(y,x).
  88.  
  89.      (3) The foregoing formulas need not be altered to cope in a
  90.          reasonable way with signed zeros and infinities on a
  91.          machine that conforms to IEEE 754; the versions of hypot
  92.          and atan2 provided for such a machine are designed to
  93.          handle all cases.  That is why atan2(+_0,-0) = +_pi, for
  94.          instance.  In general the formulas above are equivalent
  95.          to these:
  96.          r := sqrt(x*x+y*y); if r = 0 then x := copysign(1,x);
  97.          if x > 0  then theta := 2*atan(y/(r+x))
  98.                    else theta := 2*atan((r-x)/y);
  99.      except if r is infinite then atan2 will yield an appropriate
  100.      multiple of pi/4 that would otherwise have to be obtained by
  101.      taking limits.
  102.  
  103. EERRRROORR ((dduuee ttoo RRoouunnddooffff eettcc..))
  104.      Let P stand for the number stored in the computer in place
  105.      of pi = 3.14159 26535 89793 23846 26433 ... .  Let "trig"
  106.      stand for one of "sin", "cos" or "tan".  Then the expression
  107.      "trig(x)" in a program actually produces an approximation to
  108.      trig(x*pi/P), and "atrig(x)" approximates (P/pi)*atrig(x).
  109.      The approximations are close,  within 0.9 _u_l_ps for sin, cos
  110.      and atan, within 2.2 _u_l_ps for tan, asin, acos and atan2 on a
  111.      VAX.  Moreover, P = pi in the codes that run on a VAX.
  112.  
  113.      In the codes that run on other machines, P differs from pi
  114.      by a fraction of an _u_l_p; the difference matters only if the
  115.      argument x is huge, and even then the difference is likely
  116.      to be swamped by the uncertainty in x.  Besides, every tri-
  117.      gonometric identity that does not involve pi explicitly is
  118.      satisfied equally well regardless of whether P = pi.  For
  119.      instance, sin(x)**2+cos(x)**2 = 1 and
  120.      sin(2x) = 2sin(x)cos(x) to within a few _u_l_ps no matter how
  121.      big x may be.  Therefore the difference between P and pi is
  122.      most unlikely to affect scientific and engineering computa-
  123.      tions.
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Sprite v1.0               May 12, 1986                          2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. SIN              Mathematical Library Procedures              SIN
  137.  
  138.  
  139.  
  140. SSEEEE AALLSSOO
  141.      math(3M), hypot(3M), sqrt(3M), infnan(3M)
  142.  
  143. AAUUTTHHOORR
  144.      Robert P. Corbett, W. Kahan, Stuart I. McDonald, Peter Tang
  145.      and, for the codes for IEEE 754, Dr. Kwok-Choi Ng.
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. Sprite v1.0               May 12, 1986                          3
  196.  
  197.  
  198.  
  199.